<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="oneroom.admin.board.boardModel" %>
<%@ page import="oneroom.admin.code.codeModel" %>
<jsp:useBean id="dao" scope="page" class="oneroom.admin.board.boardDao" />
<jsp:useBean id="codeDao" scope="page" class="oneroom.admin.code.codeDao" />
<%
	String redirectUrl = "";
	if (session.getAttribute("id") != null &&
			((String)session.getAttribute("id")).equals("") == false) {
	} else {
		redirectUrl = "/room/member/login.jsp";
		response.sendRedirect(redirectUrl);
	}
	//기본 세트 값 시작
	String searchGubn = request.getParameter("searchGubn") == null ? "" : request.getParameter("searchGubn");
	String searchValue = request.getParameter("searchValue") == null ? "" : request.getParameter("searchValue");
	int     giSelectPage  	= Integer.parseInt(request.getParameter("txtSelectPage") == null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int     giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock") == null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	String searchBoard = request.getParameter("searchBoard") == null ? "" : request.getParameter("searchBoard");
	//기본 세트 값 끝
	String data_id = request.getParameter("data_id") == null ? "" : request.getParameter("data_id");
	dao.getHitcount(data_id);	
	boardModel model = dao.getView(data_id);
	boardModel prvModel = dao.getPrev(data_id, searchBoard,  searchGubn,  searchValue);
	boardModel nextModel = dao.getNext(data_id, searchBoard,  searchGubn,  searchValue);
	List codeList = codeDao.getDtlList("200");//게시판 관리 코드 값

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>원룸몬스터</title>

<link href="/room/css/all.css" rel="stylesheet" type="text/css" />
<script src="/room/script/swfobject_modified.js" type="text/javascript"></script>
<script src="/room/script/common.js" type="text/javascript"></script>
<script src="/room/script/jquery-1.3.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
	
	$('#btList').click(function() {
		document.getElementById("frm").action = "list.jsp";
		document.getElementById("frm").submit();
	});
	$('#btDelete').click(function() {
		document.getElementById("searchBoard").value="<%=searchBoard %>";	
		document.getElementById("gubun").value = "D";
		document.getElementById("frm").action = "dbx.jsp";
		document.getElementById("frm").submit();
	});
	$('#reWrite').click(function() {
		document.getElementById("searchBoard").value="<%=searchBoard %>";	
		document.getElementById("gubun").value = "R";
		document.getElementById("title").value = "<%=model.getTitle()%>";
		document.getElementById("frm").action = "write.jsp";
		document.getElementById("frm").submit();		
	});	
	
});
//-->
</script>
</head>

<body>
<div align="center"> 

 <div id="content">

<!----------------왼쪽---------------->  
<%@ include file="/room/common/left.jsp" %>
<!----------------왼쪽끝---------------->  

<!----------------가운데 시작----------------> 
 <div id="rgt">
  <div id="con01">
   <div class="top bb1"><img src="/room/img/txt_top.gif" /></div>
   <div id="sch-adress"></div>

   <!------------------검색박스 시작----------------------><!------------------리스트 시작----------------------><!----------------리스트 끝---------------->
<form action="update.jsp" name="frm" id="frm" method="post">
<input type="hidden" name="searchGubn" id="searchGubn"  value="<%=searchGubn %>"/>
<input type="hidden" name="searchValue" id="searchValue"  value="<%=searchValue %>"/>
<input type="hidden" name="txtSelectPage" id="txtSelectPage"  value="<%=giSelectPage %>"/>
<input type="hidden" name="txtSelectBlock" id="txtSelectBlock" value="<%=giSelectBlock %>"/> 
<input type="hidden" name="data_id" id="data_id" value="<%=data_id %>"/>
<input type="hidden" name="searchBoard" value="<%=searchBoard %>"/>
<input type="hidden" name="gubun" id="gubun" value=""/>
<input type="hidden" name="title" id="title" value="<%=model.getTitle() %>"/>
<input type="hidden" name="re_data_id" id="re_data_id" value="<%=model.getRe_data_id() %>"/>
<input type="hidden" name="board_group" id="board_group" value="<%=model.getBoard_group() %>"/>
<input type="hidden" name="deth" id="deth" value="<%=model.getDeth() %>"/>
<!-- 삭제 관련된 변수 시작 -->
<input type="hidden" name="org_file" 	value="<%=model.getOrg_file()%>"/>
<input type="hidden" name="att_file" 	value="<%=model.getAtt_file()%>"/>
<!-- 삭제 관련되 변수 끝 -->
<div class="list h550">
 <div class="pb10"><img src="/room/img/line_blue.gif" width="32" height="2" /></div>
       <div class="tit">게시판 </div>

<table width="595" border="0" cellspacing="0" cellpadding="0">
<col width="12%" />
<col width="73%" />
<col width="15%" />

  <tr>
    <td colspan="2" class=" pl10 fw bt2 bb1 h30 bg_g"><%=model.getTitle() %></td>
    <td class="ac bt2 bb1 h30 bg_g">| 
  	<%
		for(int j = 0; j<codeList.size(); j++){
			codeModel codemode = (codeModel)codeList.get(j);
	%>
		<%if(model.getBoard_kind().equals(codemode.getCode())){out.print(codemode.getCodename());} %>
	<%
		}
	%>
    </td>
    </tr>
  <tr>
    <td class="pl10  bb1 h30"><strong>첨부파일</strong> |</td>
    <td colspan="2" class="pl10 bb1 h30">
	&nbsp;<a href="/download/<%=model.getAtt_file() %>?name=<%=model.getOrg_file() %>&kind=" ><%=model.getOrg_file() %></a>
	</td>
    </tr>
  <tr>
    <td colspan="3" class=" pt20 pl20 pb30 bb1"><%=model.getContent() %></td>
    </tr>
  <tr>
    <td class="pl10 bb1 h30"><strong>이전 글</strong> |</td>
    <td colspan="2" class="f bb1 h30">
    <%if(prvModel != null){ %>
		<%=prvModel.getTitle() %>
	<%}else{ %>
		이전 글이 없습니다.
	<%} %>
	</td>
    </tr>
  <tr>
    <td class="pl10 bb1 h30"><strong>다음 글</strong> |</td>
    <td colspan="2" class=" bb1 h30">
    <%if(nextModel != null){ %>
		<%=nextModel.getTitle() %>
	<%}else{ %>
		다음 글이 없습니다.
	<%} %>
	</td>
    </tr>
</table>

<table class="pr15 pt15" align="right" width="167" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <%if(searchBoard.equals("1")){ %>
    <td> <a class="d" href="#" id="btList"><p class="btn_b47">목록</p></a></td>
  <%}else{ %> 
	  <%if(model.getReg_id().equals((String)session.getAttribute("id"))){%>
	    <td> <a class="d" href="#" onclick="document.frm.submit();"><p class="btn_g47">수정</p></a></td>
	    <td> <a class="d" href="#" id="btDelete"><p class="btn_g47">삭제</p></a></td>
	  <%} %>  
	    <td> <a class="d" href="#" id="reWrite"><p class="btn_g47">답글</p></a></td>
    <td> <a class="d" href="#" id="btList"><p class="btn_b47">목록</p></a></td>	       
  <%} %>
  </tr>
</table>
</div>
</form>

</div>  
<!----------------가운데 끝---------------->


<!----------------오른쪽 시작---------------->  
<%@ include file="/room/common/right.jsp" %>  
<!----------------오른쪽 끝---------------->
</div>


<!-------------푸터영역----------> 
<%@ include file="/room/common/footer.jsp" %> 
<!-------------푸터영역----------> 
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>
